package com.hujie.sqlqueryes.controller;

import com.hujie.sqlqueryes.dto.SqlQueryDTO;
import com.hujie.sqlqueryes.dto.DslResultDTO;
import com.hujie.sqlqueryes.service.SqlToDslConverterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    
    @Autowired
    private SqlToDslConverterService sqlToDslConverterService;
    
    @GetMapping("/")
    public String index() {
        return "SQL to DSL Converter Service is running!";
    }
    
    @GetMapping("/test")
    public DslResultDTO test() {
        SqlQueryDTO sqlQuery = new SqlQueryDTO();
        sqlQuery.setSql("SELECT * FROM users WHERE age > 18 AND name = 'John'");
        return sqlToDslConverterService.convertSqlToDsl(sqlQuery.getSql());
    }
}